﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using HL.Lib.Global;
using HL.Lib.Models;
using System.Text;
using System.Web.Script.Serialization;
namespace HL.Website.Tools
{
    /// <summary>
    /// Summary description for MMapServices
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class MMapServices : System.Web.Services.WebService
    {
       
        [WebMethod]
        public string getWard(String city)
        {
            int c = int.Parse(city);
          //  return Utils.GetSelectPrice(c, 1);
            return "";
        }

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string GetSurvey(string A,string B)
        {
            var Map = MMapLocationService.Instance.GetListDataByCondition(0, 0, 0);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(Map);
            return strJSON;
        }
        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string GetNewsList(string southWest_lat, string southWest_lng, string northEast_lat, string northEast_lng, int city, int Cate, int Price)
        {
            decimal x1 = decimal.Parse(southWest_lat);
            decimal y1 = decimal.Parse(southWest_lng);
            decimal x2 = decimal.Parse(northEast_lat);
            decimal y2 = decimal.Parse(northEast_lng);
            var Map = MMapLocationService.Instance.GetListDataByPoint(x1, y1, x2, y2, city, Cate, Price);
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strJSON = js.Serialize(Map);
            return strJSON;
        }


        [WebMethod]
        public string SaveData(int city, string Longtitude, string Lattitude, string ImgUrl, string Title, string Intro, string Detail)
        {
            var Item = new MMapLocationEntity();
            Item.City = city;
            Item.Longtitude = Longtitude;
            Item.Lattitude = Lattitude;
            Item.ImgUrl = ImgUrl;
            Item.Tittle = Title;
            Item.Content = Detail;
            Item.Intro = Intro;
            string result = MMapLocationService.Instance.Save(Item).ToString();

            return result;
        }
    }
}
